package pl.edu.agh.experts.diseases.commons;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public abstract class DiseaseAbstract implements IDisease {

	protected double stat;
	protected Set<Symptom> symptomsCounted;
	protected Map<Symptom, Double> symptoms;

	public DiseaseAbstract() {
		this.stat = 0.0;
		this.symptomsCounted = new HashSet<Symptom>();
		this.symptoms = new HashMap<Symptom, Double>();
	}

	public void excludeSymptom(Symptom symptom) {
		if (!symptomsCounted.contains(symptom)) {
			if (symptoms.containsKey(symptom)) {
				symptomsCounted.add(symptom);
			}
		}
	}

	public void updateStats(Symptom symptom, Decision decision, double weight) {
		if (!symptomsCounted.contains(symptom)) {
			if (symptoms.containsKey(symptom)) {
				switch (decision) {
				case Yes:
					stat += symptoms.get(symptom);
					symptomsCounted.add(symptom);
					break;

				case No:
					symptomsCounted.add(symptom);
					break;

				case Maybe:
					stat += (symptoms.get(symptom) * weight);
					symptomsCounted.add(symptom);
					break;
				}
			}
		}
	}

	public double getWeight() {
		return stat;
	}
	
	public Set<Symptom> getSymptomsLeft() {
		return symptoms.keySet();
	}
}
